package com.bestsoft.web.controller.flow;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bestsoft.common.annotation.Log;
import com.bestsoft.common.core.controller.BaseController;
import com.bestsoft.common.core.domain.AjaxResult;
import com.bestsoft.common.enums.BusinessType;
import com.bestsoft.flow.domain.FlowStaff;
import com.bestsoft.flow.service.IFlowStaffService;
import com.bestsoft.common.utils.poi.ExcelUtil;
import com.bestsoft.common.core.page.TableDataInfo;

/**
 * 职员信息Controller
 * 
 * @author 群星
 * @date 2023-08-05
 */
@RestController
@RequestMapping("/flow/staff")
public class FlowStaffController extends BaseController {
    @Autowired
    private IFlowStaffService flowStaffService;

    /**
     * 查询职员信息列表
     */
    @PreAuthorize("@ss.hasPermi('flow:staff:list')")
    @GetMapping("/list")
    public TableDataInfo list(FlowStaff flowStaff) {
        startPage();
        List<FlowStaff> list = flowStaffService.selectFlowStaffList(flowStaff);
        return getDataTable(list);
    }

    /**
     * 导出职员信息列表
     */
    @PreAuthorize("@ss.hasPermi('flow:staff:export')")
    @Log(title = "职员信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FlowStaff flowStaff) {
        List<FlowStaff> list = flowStaffService.selectFlowStaffList(flowStaff);
        ExcelUtil<FlowStaff> util = new ExcelUtil<FlowStaff>(FlowStaff.class);
        util.exportExcel(response, list, "职员信息数据");
    }

    /**
     * 获取职员信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('flow:staff:query')")
    @GetMapping(value = "/{dzyid}")
    public AjaxResult getInfo(@PathVariable("dzyid") String dzyid) {
        return success(flowStaffService.selectFlowStaffByDzyid(dzyid));
    }

    /**
     * 新增职员信息
     */
    @PreAuthorize("@ss.hasPermi('flow:staff:add')")
    @Log(title = "职员信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FlowStaff flowStaff) {
        return toAjax(flowStaffService.insertFlowStaff(flowStaff));
    }

    /**
     * 修改职员信息
     */
    @PreAuthorize("@ss.hasPermi('flow:staff:edit')")
    @Log(title = "职员信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FlowStaff flowStaff) {
        return toAjax(flowStaffService.updateFlowStaff(flowStaff));
    }

    /**
     * 删除职员信息
     */
    @PreAuthorize("@ss.hasPermi('flow:staff:remove')")
    @Log(title = "职员信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{dzyids}")
    public AjaxResult remove(@PathVariable String[] dzyids) {
        return toAjax(flowStaffService.deleteFlowStaffByDzyids(dzyids));
    }
}
